package org.hashdb.client;

import org.hashdb.client.view.NioIndexPage;

import java.io.IOException;
import java.util.concurrent.ExecutionException;

/**
 * Date: 2023/11/20 21:50
 *
 * @author huanyuMake-pecdle
 * @version 0.0.1
 */
public class Main {

    public static void main(String[] args) throws IOException, InterruptedException, ExecutionException {
        NioIndexPage.instance().show(args);
    }

//    public static void demo() throws IOException, InterruptedException {
//        SocketChannel socketChannel = SocketChannel.open();
//        // 连接服务器
//        socketChannel.connect(new InetSocketAddress("localhost", 3050));
//        socketChannel.configureBlocking(true);
//        System.out.println("Client connected to server...");
//
//        // 收
//        ByteBuffer receiveBuffer = ByteBuffer.allocate(1024);
//
//        // 发送数据给服务器
//        String message = "ping";
//        ByteBuffer sendBuffer = ByteBuffer.wrap(message.getBytes());
//        sendBuffer.mark();
//        for (int i = 0; i < 10; i++) {
//            // 发
//            socketChannel.write(sendBuffer);
//            sendBuffer.reset();
//            // 读取服务器的响应数据
//            int bytesRead = socketChannel.read(receiveBuffer);
//            if (bytesRead != -1) {
//                String responseData = new String(Arrays.copyOf(receiveBuffer.array(), receiveBuffer.position()));
//                System.out.println(responseData);
//            }
//            receiveBuffer.clear();
//        }
//
//        // 关闭客户端连接
//        socketChannel.write(ByteBuffer.wrap("close".getBytes()));
//        socketChannel.close();
//    }
}
